var chartDom = document.getElementById('graph1');
var myChart1 = echarts.init(chartDom);
var option;

option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {            // 坐标轴指示器，坐标轴触发有效
            type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            data: ['管理学院', '工商学院', '计算机学院', '国际学院', '建筑学院', '机械学院', '外国语学院'],
            axisTick: {
                alignWithLabel: true
            },
            axisLabel: {//修改坐标系字体颜色
                show: true,
                textStyle: {
                    color: "#8DB6DB"
                }
            },
            splitLine: { lineStyle: { color: '#283663' } }//条纹颜色
        }
    ],
    yAxis: [
        {
            splitLine: { lineStyle: { color: '#283663' } },
            type: 'value',
            min: 0,
            max: 1500,
            interval: 300,
            axisLabel: {//修改坐标系字体颜色
                show: true,
                textStyle: {
                    color: "#8DB6DB"
                }
            }
        }
    ],
    series: [
        {
            name: '直接访问',
            type: 'bar',
            barWidth: '60%',
            data: [200, 300, 300, 900, 1500, 1200, 600],
            itemStyle: { //柱状图颜色
                normal: {
                    color: '#2F89CF'
                }
            }
        }
    ]
};

option && myChart1.setOption(option);


var chartDom = document.getElementById('graph2');
var myChart2 = echarts.init(chartDom);
var option;

option = {

    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross',
            label: {
                backgroundColor: '#6a7985'
            }
        }
    },
    legend: {
        data: ['新增项目', '新增技能', '新增投递'],
        textStyle: {
            color: '#4C9BFD'          // 图例文字颜色
        }
    },

    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis: [
        {
            type: 'category',
            boundaryGap: false,
            data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月'],
            axisLabel: {//修改坐标系字体颜色
                show: true,
                textStyle: {
                    color: "#8DB6DB"
                }
            },
            splitLine: { lineStyle: { color: '#283663' } }//条纹颜色
        }
    ],
    yAxis: [
        {
            splitLine: { lineStyle: { color: '#283663' } },
            type: 'value',
            axisLabel: {//修改坐标系字体颜色
                show: true,
                textStyle: {
                    color: "#8DB6DB"
                }
            }
        }
    ],
    series: [
        {
            name: '新增项目',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            emphasis: {
                focus: 'series'
            },
            data: [120, 192, 101, 134, 90, 230, 210]
        },
        {
            name: '新增技能',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            emphasis: {
                focus: 'series'
            },
            data: [220, 182, 191, 234, 290, 330, 310]
        },
        {
            name: '新增投递',
            type: 'line',
            stack: '总量',
            areaStyle: {},
            emphasis: {
                focus: 'series'
            },
            data: [150, 232, 201, 154, 190, 330, 410]
        }

    ]
};

option && myChart2.setOption(option);


var chartDom = document.getElementById('graph3');
var myChart3 = echarts.init(chartDom);
var option;

option = {
    tooltip: {
        trigger: 'item'
    },
    legend: {
        bottom: '1%',
        left: 'center',
        textStyle: {
            color: "#8DB6DB"          // 图例文字颜色
        }
    },
    series: [
        {
            name: '年龄分布',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
                borderRadius: 10,
                borderWidth: 2
            },
            label: {
                show: false,
                position: 'center'
            },

            labelLine: {
                show: false
            },
            data: [
                { value: 20, name: '20-29岁', itemStyle: { color: "#065AAB" } },
                { value: 43, name: '30-39岁', itemStyle: { color: "#066EAB" } },
                { value: 32, name: '40-49岁', itemStyle: { color: "#06A0AB" } },
                { value: 17, name: '50-59岁', itemStyle: { color: "#0696AB" } },
                { value: 8, name: '60-69岁', itemStyle: { color: "#0682AB" } }
            ]
        }
    ]
};

option && myChart3.setOption(option);


// 基于准备好的dom，初始化echarts实例
var myChart4 = echarts.init(document.getElementById("graph4"));

var data = [90, 80, 75, 65, 65];
var titlename = ["javascript", "VUE", "jQuery", "HTML5", "CSS3"];
var valdata = ["精通", "熟练", "熟练", "掌握", "掌握"];
var myColor = ["#1089E7", "#F57474", "#56D0E3", "#F8B448", "#8B78F6"];
option = {
    //图标位置
    grid: {
        top: "10%",
        left: "22%",
        bottom: "10%"
    },
    xAxis: {
        show: false
    },
    yAxis: [{
        show: true,
        data: titlename,
        inverse: true,
        axisLine: {
            show: false
        },
        splitLine: {
            show: false
        },
        axisTick: {
            show: false
        },
        axisLabel: {
            color: "#fff",

            rich: {
                lg: {
                    backgroundColor: "#339911",
                    color: "#fff",
                    borderRadius: 15,
                    // padding: 5,
                    align: "center",
                    width: 15,
                    height: 15
                }
            }
        }
    },
    {
        show: true,
        inverse: true,
        data: valdata,
        axisLabel: {
            textStyle: {
                fontSize: 12,
                color: "#fff"
            }
        }
    }
    ],
    series: [{
        name: "条",
        type: "bar",
        yAxisIndex: 0,
        data: data,
        barCategoryGap: 50,
        barWidth: 10,
        itemStyle: {
            normal: {
                barBorderRadius: 20,
                color: function (params) {
                    var num = myColor.length;
                    return myColor[params.dataIndex % num];
                }
            }
        },
        label: {
            normal: {
                show: true,
                position: "inside",
                formatter: "{c}%"
            }
        }
    },
    {
        name: "框",
        type: "bar",
        yAxisIndex: 1,
        barCategoryGap: 50,
        data: [100, 100, 100, 100, 100],
        barWidth: 15,
        itemStyle: {
            normal: {
                color: "none",
                borderColor: "#00c1de",
                borderWidth: 3,
                barBorderRadius: 15
            }
        }
    }
    ]
};

// 使用刚指定的配置项和数据显示图表。
myChart4.setOption(option);

var chartDom = document.getElementById('graph5');
var myChart5 = echarts.init(chartDom);
var option;

option = {
    tooltip: {
        trigger: 'axis',
        axisPointer: {
            type: 'cross',
            label: {
                backgroundColor: '#6a7985'
            }
        }
    },
    legend: {
        data: ['流入', '流出'],
        textStyle: {
            color: '#4C9BFD'          // 图例文字颜色
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: ["01",
            "02",
            "03",
            "04",
            "05",
            "06",
            "07",
            "08",
            "09",
            "11",
            "12",
            "13",
            "14",
            "15",
            "16",
            "17",
            "18",
            "19",
            "20",
            "21",
            "22",
            "23",
            "24",
            "25",
            "26",
            "27",
            "28",
            "29",
            "30"],
        axisLabel: {//修改坐标系字体颜色
            show: true,
            textStyle: {
                color: "#8DB6DB"
            }
        }
    },
    yAxis: {
        type: 'value',
        splitLine: { lineStyle: { color: '#283663' } },
        axisLabel: {//修改坐标系字体颜色
            show: true,
            textStyle: {
                color: "#8DB6DB"
            }
        }
    },
    series: [
        {
            name: "流入",
            type: "line",
            symbol: "circle",
            symbolSize: 5,
            showSymbol: false,
            lineStyle: {
                normal: {
                    color: "#0184d5",
                    width: 2
                }
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1, [{
                            offset: 0,
                            color: "rgba(1, 132, 213, 0.4)"
                        },
                        {
                            offset: 0.8,
                            color: "rgba(1, 132, 213, 0.1)"
                        }
                    ],
                        false
                    ),
                    shadowColor: "rgba(0, 0, 0, 0.1)"
                }
            },
            itemStyle: {
                normal: {
                    color: "#0184d5",
                    borderColor: "rgba(221, 220, 107, .1)",
                    borderWidth: 12
                }
            },
            data: [
                30,
                40,
                30,
                40,
                30,
                40,
                30,
                60,
                20,
                40,
                20,
                40,
                30,
                40,
                30,
                40,
                30,
                40,
                30,
                60,
                20,
                40,
                20,
                40,
                30,
                60,
                20,
                40,
                20,
                40
            ]
        },
        {
            name: "流出",
            type: "line",
            symbol: "circle",
            symbolSize: 5,
            showSymbol: false,
            lineStyle: {
                normal: {
                    color: "#00d887",
                    width: 2
                }
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(
                        0,
                        0,
                        0,
                        1, [{
                            offset: 0,
                            color: "rgba(0, 216, 135, 0.4)"
                        },
                        {
                            offset: 0.8,
                            color: "rgba(0, 216, 135, 0.1)"
                        }
                    ],
                        false
                    ),
                    shadowColor: "rgba(0, 0, 0, 0.1)"
                }
            },
            itemStyle: {
                normal: {
                    color: "#00d887",
                    borderColor: "rgba(221, 220, 107, .1)",
                    borderWidth: 12
                }
            },
            data: [
                50,
                30,
                50,
                60,
                10,
                50,
                30,
                50,
                60,
                40,
                60,
                40,
                80,
                30,
                50,
                60,
                10,
                50,
                30,
                70,
                20,
                50,
                10,
                40,
                50,
                30,
                70,
                20,
                50,
                10,
                40
            ]
        }
    ]
};

option && myChart5.setOption(option);


var chartDom = document.getElementById('graph6');
var myChart6 = echarts.init(chartDom);
var option;

option = {
    legend: {
        top: 'bottom',
        textStyle: {
            color: "#8DB6DB"          // 图例文字颜色
        }
    },
    toolbox: {
        show: true,
        feature: {
            mark: { show: true },
            dataView: { show: true, readOnly: false },
            restore: { show: true },
            saveAsImage: { show: true }
        }
    },
    series: [
        {
            name: '点位统计',
            type: 'pie',
            radius: ['0', '50%'],
            center: ['50%', '50%'],
            roseType: 'area',
            itemStyle: {
                borderRadius: 8
            },
            data: [
                { value: 40, name: '广州', },
                { value: 38, name: '深圳' },
                { value: 32, name: '北京' },
                { value: 30, name: '上海' },
                { value: 28, name: '武汉' },
                { value: 22, name: '西安' },
                { value: 18, name: '其它' }
            ]
        }
    ]
};

option && myChart6.setOption(option);























 

 // 金额转换万字单位 start
 function unitConvert(num) {
    if (num) {
        var moneyUnits = ["", "万"],
            dividend = 10000,
            curentNum = num, //转换数字
            curentUnit = moneyUnits[0]; //转换单位 
        for (var i = 0; i < 2; i++) {
            curentUnit = moneyUnits[i];
            if (strNumSize(curentNum) < 5) {
                return num;
            }
        }
        curentNum = curentNum / dividend;
        var m = {
            num: 0,
            unit: ""
        }
        m.num = curentNum.toFixed(2);
        m.unit = curentUnit;
        return m.num + m.unit;
    }
}

function strNumSize(tempNum) {
    var stringNum = tempNum.toString()
    var index = stringNum.indexOf(".")
    var newNum = stringNum
    if (index != -1) {
        newNum = stringNum.substring(0, index)
    }
    return newNum.length;
}
// 金额转换万字单位 end
var myChart7 = echarts.init(document.getElementById('china-map'));
var oBack = document.getElementById("back");
var provinces = ['shanghai', 'hebei', 'shanxi', 'neimenggu', 'liaoning', 'jilin', 'heilongjiang', 'jiangsu', 'zhejiang', 'anhui', 'fujian', 'jiangxi', 'shandong', 'henan', 'hubei', 'hunan', 'guangdong', 'guangxi', 'hainan', 'sichuan', 'guizhou', 'yunnan', 'xizang', 'shanxi1', 'gansu', 'qinghai', 'ningxia', 'xinjiang', 'beijing', 'tianjin', 'chongqing', 'xianggang', 'aomen'];
var provincesText = ['上海', '河北', '山西', '内蒙古', '辽宁', '吉林', '黑龙江', '江苏', '浙江', '安徽', '福建', '江西', '山东', '河南', '湖北', '湖南', '广东', '广西', '海南', '四川', '贵州', '云南', '西藏', '陕西', '甘肃', '青海', '宁夏', '新疆', '北京', '天津', '重庆', '香港', '澳门'];
// 全国省份数据
var toolTipData = [{
    "provinceName": "北京",
    "provinceKey": 110000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 58,
    "totalPrice": 860448.7,
    "orderCount": 31744,
    "onlineCount": 0
}, {
    "provinceName": "天津",
    "provinceKey": 120000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 74,
    "totalPrice": 697438.3,
    "orderCount": 30025,
    "onlineCount": 0
}, {
    "provinceName": "河北",
    "provinceKey": 130000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 175,
    "totalPrice": 1051461.5,
    "orderCount": 50625,
    "onlineCount": 0
}, {
    "provinceName": "山西",
    "provinceKey": 140000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 73,
    "totalPrice": 432680.2,
    "orderCount": 20427,
    "onlineCount": 0
}, {
    "provinceName": "内蒙古",
    "provinceKey": 150000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 46,
    "totalPrice": 379952.5,
    "orderCount": 14585,
    "onlineCount": 0
}, {
    "provinceName": "辽宁",
    "provinceKey": 210000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 74,
    "totalPrice": 543290.6,
    "orderCount": 27143,
    "onlineCount": 0
}, {
    "provinceName": "吉林",
    "provinceKey": 220000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 25,
    "totalPrice": 234353.7,
    "orderCount": 11123,
    "onlineCount": 0
}, {
    "provinceName": "黑龙江",
    "provinceKey": 230000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 25,
    "totalPrice": 152894.8,
    "orderCount": 6481,
    "onlineCount": 0
}, {
    "provinceName": "上海",
    "provinceKey": 310000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 78,
    "totalPrice": 665877.5,
    "orderCount": 26753,
    "onlineCount": 0
}, {
    "provinceName": "江苏",
    "provinceKey": 320000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 475,
    "totalPrice": 3302139.4,
    "orderCount": 158180,
    "onlineCount": 0
}, {
    "provinceName": "浙江",
    "provinceKey": 330000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 332,
    "totalPrice": 2285259.3,
    "orderCount": 116344,
    "onlineCount": 0
}, {
    "provinceName": "安徽",
    "provinceKey": 340000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 168,
    "totalPrice": 1081322.1,
    "orderCount": 57139,
    "onlineCount": 0
}, {
    "provinceName": "福建",
    "provinceKey": 350000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 145,
    "totalPrice": 1352019.8,
    "orderCount": 65228,
    "onlineCount": 0
}, {
    "provinceName": "江西",
    "provinceKey": 360000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 103,
    "totalPrice": 689353.7,
    "orderCount": 31822,
    "onlineCount": 0
}, {
    "provinceName": "山东",
    "provinceKey": 370000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 198,
    "totalPrice": 1177320.9,
    "orderCount": 59966,
    "onlineCount": 0
}, {
    "provinceName": "河南",
    "provinceKey": 410000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 184,
    "totalPrice": 953710.6,
    "orderCount": 52829,
    "onlineCount": 0
}, {
    "provinceName": "湖北",
    "provinceKey": 420000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 125,
    "totalPrice": 890921.4,
    "orderCount": 46768,
    "onlineCount": 0
}, {
    "provinceName": "湖南",
    "provinceKey": 430000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 111,
    "totalPrice": 1007182.7,
    "orderCount": 44094,
    "onlineCount": 0
}, {
    "provinceName": "广东",
    "provinceKey": 440000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 384,
    "totalPrice": 3792306.1,
    "orderCount": 165774,
    "onlineCount": 0
}, {
    "provinceName": "广西",
    "provinceKey": 450000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 194,
    "totalPrice": 1252955,
    "orderCount": 69882,
    "onlineCount": 0
}, {
    "provinceName": "海南",
    "provinceKey": 460000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 58,
    "totalPrice": 617514,
    "orderCount": 33090,
    "onlineCount": 0
}, {
    "provinceName": "重庆",
    "provinceKey": 500000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 35,
    "totalPrice": 468892.6,
    "orderCount": 20163,
    "onlineCount": 0
}, {
    "provinceName": "四川",
    "provinceKey": 510000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 127,
    "totalPrice": 793622.7,
    "orderCount": 43625,
    "onlineCount": 0
}, {
    "provinceName": "贵州",
    "provinceKey": 520000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 78,
    "totalPrice": 659747.2,
    "orderCount": 28817,
    "onlineCount": 0
}, {
    "provinceName": "云南",
    "provinceKey": 530000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 87,
    "totalPrice": 657485.2,
    "orderCount": 30916,
    "onlineCount": 0
}, {
    "provinceName": "西藏",
    "provinceKey": 540000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 5,
    "totalPrice": 106922.4,
    "orderCount": 2470,
    "onlineCount": 0
}, {
    "provinceName": "陕西",
    "provinceKey": 610000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 65,
    "totalPrice": 589961.2,
    "orderCount": 27093,
    "onlineCount": 0
}, {
    "provinceName": "甘肃",
    "provinceKey": 620000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 40,
    "totalPrice": 248209.2,
    "orderCount": 12390,
    "onlineCount": 0
}, {
    "provinceName": "青海",
    "provinceKey": 630000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 3,
    "totalPrice": 33328.1,
    "orderCount": 1161,
    "onlineCount": 0
}, {
    "provinceName": "宁夏",
    "provinceKey": 640000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 14,
    "totalPrice": 146590.7,
    "orderCount": 5240,
    "onlineCount": 0
}, {
    "provinceName": "新疆",
    "provinceKey": 650000,
    "cityName": null,
    "cityKey": null,
    "shopCount": 43,
    "totalPrice": 294423.4,
    "orderCount": 11741,
    "onlineCount": 0
}]
var seriesData = [];
for (var i = 0; i < toolTipData.length; i++) {
    seriesData[i] = {};
    seriesData[i].name = toolTipData[i].provinceName;
    seriesData[i].value = toolTipData[i].shopCount;
    seriesData[i].provinceKey = toolTipData[i].provinceKey;
}
// 请求省市数据，传递provinceKey进行ajax请求 province(key)
var provinceData = [{
    "provinceName": null,
    "provinceKey": null,
    "cityName": "乌鲁木齐市",
    "cityKey": 650100,
    "shopCount": 17,
    "totalPrice": 89429.1,
    "orderCount": 4019,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "克拉玛依市",
    "cityKey": 650200,
    "shopCount": 1,
    "totalPrice": 363.6,
    "orderCount": 17,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "昌吉回族自治州",
    "cityKey": 652300,
    "shopCount": 3,
    "totalPrice": 2203.7,
    "orderCount": 82,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "博尔塔拉蒙古自治州",
    "cityKey": 652700,
    "shopCount": 1,
    "totalPrice": 7327.7,
    "orderCount": 236,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "巴音郭楞蒙古自治州",
    "cityKey": 652800,
    "shopCount": 2,
    "totalPrice": 28768.4,
    "orderCount": 961,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "阿克苏地区",
    "cityKey": 652900,
    "shopCount": 5,
    "totalPrice": 78415.2,
    "orderCount": 3108,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "喀什地区",
    "cityKey": 653100,
    "shopCount": 4,
    "totalPrice": 38870.1,
    "orderCount": 1477,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "和田地区",
    "cityKey": 653200,
    "shopCount": 1,
    "totalPrice": 10488,
    "orderCount": 218,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "伊犁哈萨克自治州",
    "cityKey": 654000,
    "shopCount": 6,
    "totalPrice": 32864.2,
    "orderCount": 1363,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "塔城地区",
    "cityKey": 654200,
    "shopCount": 1,
    "totalPrice": 160,
    "orderCount": 5,
    "onlineCount": 0
}, {
    "provinceName": null,
    "provinceKey": null,
    "cityName": "省直辖行政单位",
    "cityKey": 659000,
    "shopCount": 2,
    "totalPrice": 5533.4,
    "orderCount": 255,
    "onlineCount": 0
}];
var seriesDataPro = [];
for (var i = 0; i < provinceData.length; i++) {
    seriesDataPro[i] = {};
    seriesDataPro[i].name = provinceData[i].cityName;
    seriesDataPro[i].value = provinceData[i].shopCount;
}

var max = Math.max.apply(Math, seriesData.map(function(o) {
        return o.value
    })),
    min = 0; // 侧边最大值最小值
var maxSize4Pin = 40,
    minSize4Pin = 30;
// 点击返回按钮
oBack.onclick = function() {
    $('#back').addClass('hidden');
    mapName = '';
    initEcharts("china", "中国");
};

var mapName = '';

function getGeoCoordMap(name) {
    name = name ? name : 'china';
    /*获取地图数据*/
    var geoCoordMap = {};
    myChart7.showLoading(); // loading start
    var mapFeatures = echarts.getMap(name).geoJson.features;
    myChart7.hideLoading(); // loading end
    mapFeatures.forEach(function(v) {
        var name = v.properties.name; // 地区名称
        geoCoordMap[name] = v.properties.cp; // 地区经纬度
    });
    return geoCoordMap;
}

function convertData(data) { // 转换数据
    var geoCoordMap = getGeoCoordMap(mapName);
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name]; // 数据的名字对应的经纬度
        if (geoCoord) { // 如果数据data对应上，
            res.push({
                name: data[i].name,
                value: geoCoord.concat(data[i].value),
            });
        }
    }
    return res;
};
// 初始化echarts-map
initEcharts("china", "中国");

function initEcharts(pName, Chinese_) {
    var tmpSeriesData = pName === "china" ? seriesData : seriesDataPro;
    var tmp = pName === "china" ? toolTipData : provinceData;
    var option = {
        title: {
            left: 'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: function(params) { // 鼠标滑过显示的数据
                if (pName === "china") {
                    var toolTiphtml = ''
                    for (var i = 0; i < tmp.length; i++) {
                        if (params.name == tmp[i].provinceName) {
                            toolTiphtml += tmp[i].provinceName + '<br>营业额：' + unitConvert(tmp[i].totalPrice) + '<br>学生数：' + tmp[i].orderCount + '单' + '<br>校区数：' + tmp[i].shopCount;
                        }
                    }
                    return toolTiphtml;
                } else {
                    var toolTiphtml = ''
                    for (var i = 0; i < tmp.length; i++) {
                        if (params.name == tmp[i].cityName) {
                            toolTiphtml += tmp[i].cityName + '<br>营业额：' + unitConvert(tmp[i].totalPrice) + '<br>学生数：' + tmp[i].orderCount + '单' + '<br>校区数：' + tmp[i].shopCount;
                        }
                    }
                    return toolTiphtml;
                }
            }
        },
        visualMap: { //视觉映射组件
            show: true,
            min: min,
            max: max, // 侧边滑动的最大值，从数据中获取
            left: '5%',
            top: '96%',
            inverse: true, //是否反转 visualMap 组件
            // itemHeight:200,  //图形的高度，即长条的高度
            text: ['高', '低'], // 文本，默认为数值文本
            calculable: false, //是否显示拖拽用的手柄（手柄能拖拽调整选中范围）
            seriesIndex: 1, //指定取哪个系列的数据，即哪个系列的 series.data,默认取所有系列
            orient: "horizontal",
            inRange: {
                color: ['#dbfefe', '#1066d5'] // 蓝绿
            },
            textStyle:{color:'#fff'}
        },
        geo: {
            show: true,
            map: pName,
            roam: false,
            label: {
                normal: {
                    show: false
                },
                emphasis: {
                    show: false,
                }
            },
            itemStyle: {
                normal: {
                    areaColor: '#3c8dbc', // 没有值得时候颜色
                    borderColor: '#097bba',
                },
                emphasis: {
                    areaColor: '#fbd456', // 鼠标滑过选中的颜色
                }
            }
        },
        series: [{
                name: '散点',
                type: 'scatter',
                coordinateSystem: 'geo',
                data: tmpSeriesData,
                symbolSize: '1',
                label: {
                    normal: {
                        show: true,
                        formatter: '{b}',
                        position: 'right'
                    },
                    emphasis: {
                        show: true
                    }
                },
                itemStyle: {
                    normal: {
                        color: 'rgb(255,255,255,0)' // 字体颜色
                    }
                }
            },
            {
                name: Chinese_ || pName,
                type: 'map',
                mapType: pName,
                roam: false, //是否开启鼠标缩放和平移漫游
                data: tmpSeriesData,
                // top: "3%",//组件距离容器的距离
                // geoIndex: 0,
                // aspectScale: 0.75,       //长宽比
                // showLegendSymbol: false, // 存在legend时显示
                selectedMode: 'single',
                label: {
                    normal: {
                        show: true, //显示省份标签
                        textStyle: {
                            color: "#895139"
                        } //省份标签字体颜色
                    },
                    emphasis: { //对应的鼠标悬浮效果
                        show: true,
                        textStyle: {
                            color: "#323232"
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        borderWidth: .5, //区域边框宽度
                        borderColor: '#0550c3', //区域边框颜色
                        areaColor: "#0b7e9e", //区域颜色
                    },
                    emphasis: {
                        borderWidth: .5,
                        borderColor: '#4b0082',
                        areaColor: "#ece39e",
                    }
                }
            },
            {
                name: '点',
                type: 'scatter',
                coordinateSystem: 'geo',
                symbol: 'pin', //气泡
                symbolSize: function(val) {
                    var a = (maxSize4Pin - minSize4Pin) / (max - min);
                    var b = minSize4Pin - a * min;
                    b = maxSize4Pin - a * max;
                    return a * val[2] + b;
                },
                label: {
                    normal: {
                        show: true,
                        formatter: function(params) {
                            return params.data.value[2];
                        },
                        textStyle: {
                            color: '#fff',
                            fontSize: 9
                        }
                    }
                },
                itemStyle: {
                    normal: {
                        color: 'red' //标志颜色'#F62157'
                    }
                },
                zlevel: 6,
                data: convertData(tmpSeriesData),
            },
        ]
    };
    // 针对海南放大
    if (pName == '海南') {
        option.series[1].center = [109.844902, 19.0392];
        option.series[1].layoutCenter = ['50%', '50%'];
        option.series[1].layoutSize = "300%";
    } else { //非显示海南时，将设置的参数恢复默认值
        option.series[1].center = undefined;
        option.series[1].layoutCenter = undefined;
        option.series[1].layoutSize = undefined;
    }
    myChart7.setOption(option);
    /* 响应式 */
    $(window).resize(function() {
        myChart7.resize();
    });

    myChart7.off("click");

    if (pName === "china") { // 全国时，添加click 进入省级
        myChart7.on('click', function(param) {
            // console.log(param.name);
            if (param.data && param.data.provinceKey) {
                var key = param.data.provinceKey;
                // province(key);  省份请求
                if (provinceData.length) {
                    $('#back').removeClass('hidden');
                    // 遍历取到provincesText 中的下标  去拿到对应的省js
                    for (var i = 0; i < provincesText.length; i++) {
                        if (param.name === provincesText[i]) {
                            mapName = provincesText[i];
                            //显示对应省份的方法
                            showProvince(provinces[i], provincesText[i]);
                            break;
                        }
                    }
                }
            }
        });
    } else { // 省份，添加双击 回退到全国
        myChart7.on("dblclick", function() {
            $('#back').addClass('hidden');
            mapName = '';
            initEcharts("china", "中国");
        });
    }
}

// 展示对应的省
function showProvince(pName, Chinese_) {
    //这写省份的js都是通过在线构建工具生成的，保存在本地，需要时加载使用即可，最好不要一开始全部直接引入。
    loadBdScript('$' + pName + 'JS', './js/map/province/' + pName + '.js', function() {
        initEcharts(Chinese_);
    });
}

// 加载对应的JS
function loadBdScript(scriptId, url, callback) {
    var script = document.createElement("script");
    script.type = "text/javascript";
    if (script.readyState) { //IE
        script.onreadystatechange = function() {
            if (script.readyState === "loaded" || script.readyState === "complete") {
                script.onreadystatechange = null;
                callback();
            }
        };
    } else { // Others
        script.onload = function() {
            callback();
        };
    }
    script.src = url;
    script.id = scriptId;
    document.getElementsByTagName("head")[0].appendChild(script);
};


window.addEventListener("resize", function () {
    myChart1.resize();
    myChart2.resize();
    myChart3.resize();
    myChart4.resize();
    myChart5.resize();
    myChart6.resize();
    myChart7.resize();
});